package com.qf.controller;

import com.qf.pojo.SCMusic;
import com.qf.service.SCMusicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.mail.MailProperties;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController("/SCMusic")
public class SCMusicController {
    @Autowired
    SCMusicService scMusicService;

    @RequestMapping("/findSCMusicAll")
    public List<SCMusic> findAll(){
        return scMusicService.findAll();
    }

    @RequestMapping("/findSCMusicByUid")
    public List<SCMusic> findByUid(@RequestBody Map map){
        Integer id = (Integer) map.get("id");
        return scMusicService.findByUid(id);
    }

    @RequestMapping("/addAndUpdateSCMusic")
    public String addAndUpdate(SCMusic scMusic){
        SCMusic scMusic1 = scMusicService.addAndUpdate(scMusic);
        if(scMusic1!=null){
            return "success";
        }else{
            return "fail";
        }
    }

    @RequestMapping("/deleteByScid")
    public void delete(@RequestBody Map map){
        Integer id = (Integer)map.get("id");
        scMusicService.delete(id);
    }
}
